package com.global.gbinventory.barang.util;

import java.io.File;

import javax.swing.filechooser.FileFilter;

public class ImageFilter extends FileFilter{

	//Accept all directories and all gif, jpg, jpeg, tif, tiff, or png files
	@Override
	public boolean accept(File f) {
		if(f.isDirectory()){
			return true;
		}
		
		String ext = ImageUtils.getExtension(f);
		if(ext != null){
			if	( ext.equals(ImageUtils.jpeg) ||
				  ext.equals(ImageUtils.jpg) ||
				  ext.equals(ImageUtils.gif) ||
				  ext.equals(ImageUtils.png) ||
				  ext.equals(ImageUtils.tif) ||
				  ext.equals(ImageUtils.tiff)){
				return true;
			}else{
				return false;
			}
		}
		
		return false;
	}

	//The description of this filter
	@Override
	public String getDescription() {
		return "Only Images";
	}
	
}
